package struct
{
	import main.ClientConstants;
	
	public class SelfPath extends StructBase
	{
		public var id:int;
		public var type:int;
		public var name:String;
		public var desc:String;
		public var info:Array;
		public var totalDays:Number;
		
		public function SelfPath()
		{
		}
		
		private function createInfo(list:Array):void
		{
			var infoList:Array = [];
			for(var i:int = 0;i < list.length;i++){
				var partInfoList:Array = [];
				
				//				if(list[i] is String){
				var daliyList:Array = list[i].split("^");
				for(var j:int = 0;j < daliyList.length;j++){
					var itemList:Array = daliyList[j].split("@");
					var visitItem:*;
					if(itemList[1] == ClientConstants.VISIT_TYPE_SCENIC){
						visitItem = new Scenic;
						visitItem.init(_uri,_xmlLoaderManager);
						visitItem.id = itemList[0];
						visitItem.type = itemList[1];
						visitItem.initThis();
					}else if(itemList[1] == ClientConstants.VISIT_TYPE_EATING){
						visitItem = new Restaurant;
						visitItem.init(_uri,_xmlLoaderManager);
						visitItem.id = itemList[0];
						visitItem.type = itemList[1];
						visitItem.initThis();
					}else if(itemList[1] == ClientConstants.VISIT_TYPE_FUN){
						visitItem = new ScenicShop;
						visitItem.init(_uri,_xmlLoaderManager);
						visitItem.id = itemList[0];
						visitItem.type = itemList[1];
						visitItem.initThis();
					}else if(itemList[1] == ClientConstants.VISIT_TYPE_HOTEL){
						visitItem = new Hotel;
						visitItem.init(_uri,_xmlLoaderManager);
						visitItem.id = itemList[0];
						visitItem.type = itemList[1];
						visitItem.initThis();
					}
					partInfoList.push(visitItem);
				}
				infoList.push(partInfoList);
			}
			//			}
			this.info = infoList;
		}
		
		public function initList():void
		{
//			createInfo(this.info);
			createSelfInfo(this.info);
		}
		
		public function initWithData(obj:Object):void
		{
			if(obj){
				this.id = obj.id;
				this.type = obj.type;
				this.name = obj.name;
				
//				createInfo(obj.info);
				createSelfInfo(obj.info);
				
				this.desc = obj.desc;
				this.totalDays = obj.totalDays;
			}
		}
		
		private function createSelfInfo(list:Array):void
		{
			var infoList:Array = [];
			for(var i:int = 0;i < list.length;i++){
				var partInfoList:Array = [];
				
				var daliyList:Array = list[i];
				for(var j:int = 0;j < daliyList.length;j++){
					var visitItem:*;
					if(daliyList[j].type == ClientConstants.VISIT_TYPE_SCENIC){
						visitItem = new Scenic;
						visitItem.init(_uri,_xmlLoaderManager);
						visitItem.id = daliyList[j].id;
						visitItem.type = daliyList[j].type;
						visitItem.initThis();
					}else if(daliyList[j].type == ClientConstants.VISIT_TYPE_EATING){
						visitItem = new Restaurant;
						visitItem.init(_uri,_xmlLoaderManager);
						visitItem.id = daliyList[j].id;
						visitItem.type = daliyList[j].type;
						visitItem.initThis();
					}else if(daliyList[j].type == ClientConstants.VISIT_TYPE_FUN){
						visitItem = new ScenicShop;
						visitItem.init(_uri,_xmlLoaderManager);
						visitItem.id = daliyList[j].id;
						visitItem.type = daliyList[j].type;
						visitItem.initThis();
					}else if(daliyList[j].type == ClientConstants.VISIT_TYPE_HOTEL){
						visitItem = new Hotel;
						visitItem.init(_uri,_xmlLoaderManager);
						visitItem.id = daliyList[j].id;
						visitItem.type = daliyList[j].type;
						visitItem.initThis();
					}
					partInfoList.push(visitItem);
				}
				infoList.push(partInfoList);
			}
			this.info = infoList;
		}
	}
}